<?php
/** @var FormController $this */
/** @var Form $model */
$this->pageTitle = Form::label(2);
$this->breadcrumbs = array(
    Yii::t('app', 'Dashboard') => Yii::app()->homeUrl,
    Form::label(2) => array('default/index'),
    $this->pageTitle,
);
$this->menu = array(
    array('label' => Yii::t('noseyModule.app', 'Manage'), 'url' => array('default/index')),
    array('label' => Yii::t('noseyModule.app', 'Create'), 'url' => array('form/create')),
);
?>

<div class="widget blue">
    <div class="widget-title">
        <h4><i class="icon-plus"></i> <?php echo Yii::t('noseyModule.app', 'Reporte') . ' ' . Form::label(); ?></h4>
        <span class="tools">
            <a href="javascript:;" class="icon-chevron-down"></a>
            <!--a href="javascript:;" class="icon-remove"></a-->
        </span>
    </div>
    <div class="widget-body">
        <div class="row-fluid">
            <?php
            $form = $this->beginWidget('ext.AweCrud.components.AweActiveForm', array(
                'type' => 'horizontal',
                'id' => 'reporte',
            ));
            ?>

            <?php
            echo $form->datepickerRow($model, 'inicio', array(
                'name' => 'inicio',
                'options' => array(
                    'format' => 'dd/mm/yyyy',
            )));
            echo $form->datepickerRow($model, 'fin', array(
                'name' => 'fin',
                'options' => array(
                    'format' => 'dd/mm/yyyy',
            )));
            ?>



            <?php
            $this->widget('bootstrap.widgets.TbButton', array(
                'buttonType' => 'submit',
                'type' => 'primary',
                'label' => Yii::t('AweCrud.app', 'Generar Reporte'),
            ));
            ?>


            <?php $this->endWidget(); ?>
        </div>
        <div class="row-fluid">




            <?php $count = 1;
            foreach ($model->sections as $section):
                ?>
                <?php foreach ($section->fields as $field): ?>
                    <?php
                    $options = $field->generatePieReport($model->inicio, $model->fin);

                    if ($options) {
                        echo '<div class="span6">';
                        $this->Widget('ext.highcharts.HighchartsWidget', array(
                            'scripts' => array(
                                'modules/exporting', // adds Exporting button/menu to chart
                            ),
                            'options' => $options
                        ));
                        echo '</div>';
                        if ($count % 2 == 0)
                            echo '</div><div class="row-fluid">';
                        $count++;
                    }
                    ?>
                <?php endforeach; ?>
            <?php endforeach; ?>
        </div>
    </div>
</div>